package com.gome.base;

import com.gome.vue4j.core.AbstractVue4jComponent;
import com.gome.vue4j.core.Vue4jLoader;
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.fxml.FXML;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class L1Bind extends Application {

    @Override
    public void start(Stage stage) throws Exception {
        Scene scene = Vue4jLoader.loadScene(new L1BindComponent(), 320, 200);
        stage.setScene(scene);
        stage.setTitle("直接fxml方式,小型组件勉强可用");
        stage.show();
    }
}

class L1BindComponent extends AbstractVue4jComponent {
    @Override
    public CharSequence render() {
        imports(VBox.class, Insets.class, Label.class, Button.class);
        return "<VBox alignment=\"CENTER\" spacing=\"20.0\" xmlns:fx=\"http://javafx.com/fxml\">\n" +
                "        <Label text=\"${welcomeText}\" />\n" +
                "        <Button text=\"Hello!\" onAction=\"#onHelloButtonClick\"/>\n" +
                "</VBox>";
    }

    @FXML
    StringProperty welcomeText = new SimpleStringProperty();

    @FXML
    void onHelloButtonClick(){
        welcomeText.set("hello world!");
    }
}

